﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.SharePoint;

namespace SPREST.Models
{
    public static class SiteExtensionMethods
    {
        public static List<Site> Convert(this SPWebCollection webCollection)
        {            
            List<Site> sites = new List<Site>();

            foreach (SPWeb web in webCollection)
            {                
                sites.Add(web.Convert());
            }
            return sites;
            
        }

        public static Site Convert(this SPWeb web)
        {
            return new Site { ID = web.ID.ToString(), Title = web.Title };
        }

    }
}
